import time

from selenium import webdriver
from selenium.webdriver.common.by import By

# 1.创建浏览器驱动对象
driver=webdriver.Chrome()
# 2.通过get方法获取网页
driver.get("http://localhost:8081/regA.html")
# 获取当前窗口的句柄值
driver.find_element(By.CSS_SELECTOR,"#h1").click()
current_handle=driver.current_window_handle

print(current_handle)
# 获取所有窗口的句柄值
handles=driver.window_handles
print( handles)
# 怎么切换窗口
driver.switch_to.window(handles[1])
time.sleep(2)
# css #chat-textarea
driver.find_element(By.CSS_SELECTOR,"#chat-textarea").send_keys("hello")
time.sleep(2)
# css  #chat-submit-button
driver.find_element(By.CSS_SELECTOR,"#chat-submit-button").click()
time.sleep(2)
# 4.关闭浏览器对象
driver.quit()  # 关闭浏览器